<?php
header("Content-type: text/html; charset=utf-8");
session_start();
//获取验证码
$code = isset($_POST['code'])?$_POST['code']:'';
if($code){
    if($code != $_SESSION['vdcode']){
        echo "<script>alert('验证码错误');</script>";
    }else{
        echo "<script>alert('验证码正确');</script>";
    }
    
}
?>


<html>
    <head>
        <title>验证码测试</title>
    </head>
    <body>
        <script type="text/javascript">
            function getvcode(obj){
                var mytimes=new Date();
                mytimes=mytimes.getTime();
                obj.src="./vcode.php?time="+mytimes;
            }
        </script>
        <form action="" method="post">
            <input name="code" value=""/><img src="vcode.php" onclick="getvcode(this)"/>
            <input type="submit" value="提交"/>
        </form>
    </body>
</html>

